<template>
  <div class="dataInfoL">
    <div>
      <div class="trendBox">
        <p class="title">每日使用人数趋势图</p>
        <div class="trendChart">
          <lineChart
            :xData="xData1"
            :series1="yData1"
            name1="使用人数"
            v-if="xData1.length != 0 && yData1 != null"
          />
          <div v-if="!xData1.length&&!loading1" class="zw">
            <img src="@/assets/liu/zw.png" />
            <p>暂无数据</p>
          </div>
          <div
            v-loading="loading1"
            v-if="loading1"
            class="loading"
            element-loading-text="拼命加载中..."
            element-loading-spinner="el-icon-loading"
          ></div>
        </div>
      </div>
      <div class="trendBox">
        <p class="title">使用人群行业分布</p>
        <div class="trendChart">
          <BigPie :valueData="pieData" v-if="pieData.length" />
          <div v-if="!pieData.length&&!loading" class="zw">
            <img src="@/assets/liu/zw.png" />
            <p>暂无数据</p>
          </div>
          <div
            v-loading="loading"
            v-if="loading"
            class="loading"
            element-loading-text="拼命加载中..."
            element-loading-spinner="el-icon-loading"
          ></div>
        </div>
      </div>
    </div>
    <div class="posRe">
      <p class="title">播放量趋势图</p>
      <div class="topicVideoChart">
        <lineChart
          :xData="xData1"
          :series1="yData2"
          name1="播放量"
          v-if="xData1.length != 0 && yData2 != null"
        />
        <div v-if="!xData1.length&&!loading1" class="zw">
          <img src="@/assets/liu/zw.png" />
          <p>暂无数据</p>
        </div>
        <div
          v-loading="loading1"
          v-if="loading1"
          class="loading"
          element-loading-text="拼命加载中..."
          element-loading-spinner="el-icon-loading"
        ></div>
      </div>
    </div>
    <p class="title">同款话题视频</p>
    <div class="timeBox">
      <el-date-picker
        class="long_time"
        v-model="liveTime"
        type="daterange"
        range-separator="至"
        start-placeholder="开始时间"
        end-placeholder="结束时间"
        prefix-icon="el-icon-arrow-down"
        unlink-panels
        :clearable="false"
        @change="onPick1"
        :picker-options="pickeroptions"
        value-format="yyyy-MM-dd"
      ></el-date-picker>
      <div class="searchBox">
        <el-input
          type="text"
          v-model="keyWords"
          @keyup.enter.native="Search"
          placeholder="请输入视频名称"
        ></el-input>
        <div class="imgBox" @click="Search">
          <!-- <img src="@/assets/wang/talentCompare/search.png" /> -->
        </div>
      </div>
    </div>
    <div class="list_wrap">
      <ul class="ulHeader">
        <li>视频</li>
        <li>达人</li>
        <li v-if="sort==2">
          发布时间
          <img src="@/assets/meng/down_up.png" alt />
        </li>
        <li v-else style="cursor: pointer;" @click="sort_fun(2)">
          发布时间
          <img src="@/assets/meng/no_down_up.png" alt />
        </li>
        <li v-if="sort==1">
          点赞数
          <img src="@/assets/meng/down_up.png" alt />
        </li>
        <li v-else style="cursor: pointer;" @click="sort_fun(1)">
          点赞数
          <img src="@/assets/meng/no_down_up.png" alt />
        </li>

        <li v-if="sort==3">
          评论数
          <img src="@/assets/meng/down_up.png" alt />
        </li>
        <li v-else style="cursor: pointer;" @click="sort_fun(3)">
          评论数
          <img src="@/assets/meng/no_down_up.png" alt />
        </li>
        <li v-if="sort==4">
          转发数
          <img src="@/assets/meng/down_up.png" alt />
        </li>
        <li v-else style="cursor: pointer;" @click="sort_fun(4)">
          转发数
          <img src="@/assets/meng/no_down_up.png" alt />
        </li>
      </ul>
      <ul class="ulCon" v-if="TopicList.length">
        <li v-for="item,i in TopicList" :key="i+'ss'">
          <div>
            <img @click="goDy(item.url)" :src="item.thumPic" alt />
            <p @click="goDy(item.url)">{{item.title}}</p>
          </div>
          <div>
            <img :src="item.logo" @click="talentDetails(item.authorId)" alt />
            <div class="slh">
              <p
                class="nickName"
                @click="talentDetails(item.authorId)"
              >{{item.nickName}}</p>
              <p>抖音号：{{item.uniqueId}}</p>
            </div>
          </div>
          <div>
            <p>{{timestamp(item.releaseTime,'Y-M-D h:m')}}</p>
          </div>
          <div>
            <p>{{format_num(item.favoriteCount)}}</p>
          </div>
          <div>
            <p>{{format_num(item.commentCount)}}</p>
          </div>
          <div>
            <p>{{format_num(item.shareCount)}}</p>
          </div>
        </li>
      </ul>
      <div
        v-loading="loading2"
        v-if="loading2"
        class="loading"
        element-loading-text="拼命加载中..."
        element-loading-spinner="el-icon-loading"
      ></div>
      <div v-if="!TopicList.length&&!loading2" class="zw">
        <img src="@/assets/liu/zw.png" />
        <p>暂无数据</p>
      </div>
      <div class="pageBox" v-if="count>Size&&!loading2">
        <el-pagination
          background
          layout="prev, pager, next, jumper"
          :total="count"
          :page-size="Size"
          :current-page="page"
          @current-change="get_data"
          :hide-on-single-page="true"
        ></el-pagination>
      </div>
    </div>
  </div>
</template>

<script>
import lineChart from './KChart.vue';
import BigPie from '@/pages/wang/talent/tdetails/component/BigPie';
export default {
  props: ['title'],
  data() {
    return {
      loading: false,
      loading1: false,
      loading2: false,
      sort: 2,
      Size: 10,
      count: null,
      page: 1,
      xData1: [],
      TopicList: [],
      keyWords: '',
      pieData: [],
      liveTime: [], // 选择时间 不可选的日期
      pickeroptions: {
        disabledDate: time => {
          // let startDay = new Date("2021/3/1");
          return (
            time.getTime() < Date.now() - 180 * 24 * 60 * 60 * 1000 ||
            time.getTime() > Date.now()
          ); // 返回 所有时间 大于 当前时间
        }
      }
    };
  },
  components: { BigPie, lineChart },
  computed: {},
  created() {
    this.liveTime = [
      this.timestamp(Date.now() / 1000 - 86400 * 6, 'Y-M-D'),
      this.timestamp(Date.now() / 1000, 'Y-M-D')
    ];
    this.getTradeRatio();
    this.getTradeRatio1();
    // this.GetTopicAwemes1();
  },
  mounted() {},
  watch: {
    title(n) {
      this.GetTopicAwemes1();
    },
    keyWords(n) {
      if (!n) {
        this.GetTopicAwemes1();
      }
    }
  },
  methods: {
    // 达人详情
    talentDetails(id) {
      let router = this.$router.resolve({
        path: `/talent_main/tdetails/${id}/${0}`
      });
      window.open(router.href, '_blank');
    },
    goDy(u) {
      window.open(u);
    },
    //   分页
    get_data(page) {
      this.page = page;
      this.TopicList = [];
      this.GetTopicAwemes1();
    },
    //   列表
    GetTopicAwemes1() {
      this.loading2 = true;
      this.$axios
        .post('/api/topic/GetTopicAwemes1', {
          Topic: this.title,
          title: this.keyWords.trim(),
          SortType: this.sort,
          ReleaseTime: this.liveTime[0] + '-' + this.liveTime[1],
          Index: this.page,
          Size: this.Size
        })
        .then(res => {
          this.loading2 = false;
          if (res.data.code == 0) {
            this.count = res.data.data.count;
            this.TopicList = res.data.data.data;
          }
        });
    },
    // 图表
    getTradeRatio() {
      this.loading1 = true;
      let that = this;
      that.$axios
        .get('/api/topic/GetTradeRatio', {
          params: {
            topicId: that.$route.params.id,
            // topicId: '1380949933',
            chartType: 1 //1:使用人数（datas1） 播放量增量 (datas2) 2:行业分析
          }
        })
        .then(res => {
          this.loading1 = false;
          if (res.data.code == 0) {
            that.yData1 = res.data.data.datas1; //使用人数
            if (res.data.data.dates != null) {
              res.data.data.dates.forEach(element => {
                that.xData1.push(that.timestamp(element, 'M/D'));
                return that.xData1;
              });
            }
            that.yData2 = res.data.data.datas2; //播放量增量
          }
        })
        .catch(err => {
          console.log(err);
        });
    },
    // 图表
    getTradeRatio1() {
      this.loading = true;
      let that = this;
      that.$axios
        .get('/api/topic/GetTradeRatio', {
          params: {
            topicId: that.$route.params.id,
            // topicId: '1380949933',
            chartType: 2 //1:使用人数（datas1） 播放量增量 (datas2) 2:行业分析
          }
        })
        .then(res => {
          this.loading = false;
          if (res.data.code == 0) {
            that.pieData = res.data.data;
          }
        })
        .catch(err => {
          console.log(err);
        });
    },
    //   表格头部排序
    sort_fun(parm01) {
      switch (parm01) {
        case 1:
          this.sort = 1;
          break;
        case 2:
          this.sort = 2;
          break;
        case 3:
          this.sort = 3;
          break;
        case 4:
          this.sort = 4;
          break;
      }
      this.TopicList = [];
      this.GetTopicAwemes1();
    },
    Search() {
      this.page = 1;
      this.GetTopicAwemes1();
    },
    onPick1() {
      //   this.KindName = '';
      //   // this.vidio = [];
      //   this.page = 1;
      //   this.searchpro = [];
      //   this.getTime();
      this.GetTopicAwemes1();
    }
  }
};
</script>

<style lang="less" scoped>
.dataInfoL {
  min-width: 807px;
  // min-height: 120vh;
  // padding-top: 20px;
  padding-left: 20px;
  padding-right: 20px;
  width: 100%;
  // height: 100%;
  box-sizing: border-box;
  > div {
    display: flex;
    &:nth-child(1) {
      justify-content: space-between;
      > div {
        width: 47%;
        margin-bottom: 30px;
        .trendChart {
          position: relative;
          width: 100%;
          height: 241px;
        }
      }
    }
  }
  .title {
    font-size: 16px;
    font-weight: 600;
    color: #222222;
    position: relative;
    text-indent: 10px;
    width: 100%;
    height: 21px;
    margin-bottom: 20px;
    &::after {
      content: '';
      position: absolute;
      left: 0;
      top: 50%;
      transform: translateY(-50%);
      width: 4px;
      height: 16px;
      background-color: #fd7f2c;
      border-radius: 2px;
    }
  }
  .topicVideoChart {
    width: 100%;
    height: 241px;
    margin-bottom: 39px;
  }
  // 搜索框
  .searchBox {
    width: 308px;
    height: 32px;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid #e5e5e5;
    overflow: hidden;
    margin-left: 9px;
    .imgBox:hover {
      background: url('../../../assets/wang/talentCompare/search.png') no-repeat
          10px 7px,
        #fff;
      background-size: 15px 15px;
    }
    .imgBox {
      width: 40px;
      height: 30px;
      border-radius: 0px 4px 4px 0px;
      cursor: pointer;
      display: grid;
      place-items: center;
      background: url('../../../assets/wang/talentCompare/search-nohover.png')
          no-repeat 10px 7px,
        #fff;
      background-size: 15px 15px;
      img {
        width: 15px;
        height: 15px;
      }
    }
  }
  .timeBox {
    margin-bottom: 10px;
  }
  .ulHeader {
    width: 100%;
    display: flex;
    height: 48px;
    background-color: #f5f9ff;
    border-radius: 4px 4px 0px 0px;
    li {
      align-self: center;
      font-size: 14px;
      font-weight: 600;
      color: #555555;
      > img {
        width: 5px;
        height: 12px;
      }
      &:nth-child(1) {
        width: 30%;
        padding-left: 46px;
      }
      &:nth-child(2) {
        width: 22%;
      }
      &:nth-child(3),
      &:nth-child(4),
      &:nth-child(5),
      &:nth-child(6) {
        text-align: center;
        width: 12%;
      }
    }
  }
  .ulCon {
    width: 100%;
    // min-height: 800px;
    li {
      width: 100%;
      height: 78px;
      border-bottom: 1px solid #efefef;
      display: flex;
      > div {
        height: 100%;
        &:nth-child(1) {
          padding-left: 35px;
          width: 30%;
          display: flex;
          img {
            align-self: center;
            width: 50px;
            height: 50px;
            flex: 0 0 50px;
            background-color: #fd7f2c;
            border-radius: 6px;
            cursor: pointer;
            margin-right: 10px;
          }
          > p {
            align-self: center;
            width: 232px;
            // height: 35px;
            font-size: 14px;
            font-weight: 600;
            cursor: pointer;
            color: #222222;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 2;
            overflow: hidden;
            &:hover {
              color: #ff924b;
            }
          }
        }
        &:nth-child(2) {
          width: 22%;
          display: flex;
          height: 100%;
          > img {
            align-self: center;
            width: 50px;
            cursor: pointer;
            height: 50px;
            background-color: #000000;
            border-radius: 50%;
          }
          > div {
            align-self: center;
            margin-left: 10px;
          }

          p {
            white-space: nowrap;
            &:nth-child(1) {
              font-size: 14px;
              font-weight: 600;
              color: #222222;
            }
            &:nth-child(2) {
              font-size: 13px;
              color: #888888;
            }
          }
        }
        &:nth-child(3),
        &:nth-child(4),
        &:nth-child(5),
        &:nth-child(6) {
          // white-space: nowrap;
          // line-height: 79px;
          text-align: center;
          display: flex;
          align-self: center;
          text-align: center;
          width: 12%;
          p {
            width: 100%;
            text-align: center;
            align-self: center;
          }
        }
      }
    }
  }
  .list_wrap {
    display: inline-block;
    position: relative;
    min-height: 450px;
    width: 100%;
  }
  .posRe {
    display: block;
    position: relative;
  }
  .nickName {
    width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    &:hover {
      color: #ff924b !important;
    }
  }
  .slh {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    p {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }
}
</style>
